package com.gem.netty.service.card;

import com.gem.entity.Game;
import com.gem.enums.ClientMessageType;
import com.gem.enums.GameRoundStageType;
import com.gem.enums.MessageColorType;
import com.gem.factory.game.GameFactory;
import com.gem.netty.entity.ClientContent;
import com.gem.netty.entity.CurrentUser;
import com.gem.pipeline.BusinessProcess;
import com.gem.pipeline.ProcessContext;
import com.gem.utils.R;

/**
 * Author: Xhy
 * CreateTime: 2022-09-25 14:06
 * 是否换牌回合
 */
public class IsSwapCardRoundService implements BusinessProcess<ClientContent> {
    @Override
    public void process(ProcessContext<ClientContent> context) {
        Game game = GameFactory.get(context.getData().getRoomId());
        CurrentUser user = game.getUsers().get(game.getCurrentIndex());
        if (user.getState() != GameRoundStageType.SWAP_CARD.type){
            context.setNeedBreak(true);
            context.setResult(R.error().data("color", MessageColorType.SYSTEM_MESSAGE.type).message("不是换牌回合").type(ClientMessageType.GET_CARD.type));

        }
    }
}
